package top.lidee.module.backendApi.twice.management.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.lidee.common.service.twice.management.TAreaCodeService;
import top.lidee.framework.result.PageUtils;
import top.lidee.framework.result.ResponseResult;
import top.lidee.repository.model.twice.pojo.management.TAreaCodeEntity;

import java.util.Arrays;
import java.util.Map;

/**
 * 蚂蚁金服地区码
 *
 * @author zhangzhan
 * @email 52194440@qq.com
 * @date 2024-09-27 18:32:11
 */
@Api("蚂蚁金服地区码")
@RestController
@RequestMapping("/backendApi/tareacode")
public class TAreaCodeController {
    @Autowired
    private TAreaCodeService tAreaCodeService;

    /**
     * 列表
     */
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ApiOperation(value = "蚂蚁金服地区码列表")
    public ResponseResult list(@RequestBody Map<String, Object> params){
        PageUtils page = tAreaCodeService.queryPage(params);

        return ResponseResult.okResultPage("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping(value = "/info/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "蚂蚁金服地区码信息")
    public ResponseResult info(@PathVariable("id") Integer id){
		TAreaCodeEntity tAreaCode = tAreaCodeService.getById(id);

        return ResponseResult.okResultPage("TAreaCode", tAreaCode);
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ApiOperation(value = "蚂蚁金服地区码保存")
    public ResponseResult save(@RequestBody TAreaCodeEntity tAreaCode){
		tAreaCodeService.save(tAreaCode);

        return ResponseResult.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update",method = RequestMethod.PUT)
    @ApiOperation(value = "蚂蚁金服地区码修改")
    public ResponseResult update(@RequestBody TAreaCodeEntity tAreaCode){
		tAreaCodeService.updateById(tAreaCode);

        return ResponseResult.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete",method = RequestMethod.DELETE)
    @ApiOperation(value = "蚂蚁金服地区码删除")
    public ResponseResult delete(@RequestBody Integer[] ids){
		tAreaCodeService.removeByIds(Arrays.asList(ids));

        return ResponseResult.ok();
    }

}
